<?php

$app = [];
$app['config'] = require 'config.php'; 
require 'Core/DataBase/ConnetDB.php';
require 'Request/VideoRequest.php';

session_start();
if(isset($_SESSION["accountid"])){
	$userid = $_SESSION["accountid"];
}

$pdo = ConnetDB::make($app['config']['database']);
$quesy = new VideoRequest($pdo);

if(isset($_POST['connet'])){
	$classpost = $_POST['connet'];
}else{
	exit("非法访问！你的请求已被拒接！");
}

if(isset($_POST['class'])){
	$classvideo = $_POST['class'];
}

if(isset($_POST['id'])){
	$id = $_POST['id'];
}

if(isset($_POST['userName'])){
	$userName = $_POST['userName'];
}

if(isset($_POST['pwd'])){
	$pwds = md5($_POST['pwd']);
}

if (isset($_POST['account']) and isset($_POST['password'])){
	$account = $_POST['account'];
	$password = md5($_POST['password']);
}

if($classpost == "GetVideo"){
	$videos = $quesy -> GetVideo($classvideo,$userid);
	echo json_encode($videos, JSON_UNESCAPED_UNICODE);
}

if($classpost == "loginout"){
	session_start();
	unset($_SESSION["account"]);
	unset($_SESSION["accountid"]);
	unset($_SESSION["name"]);
	unset($_SESSION["isloader"]);
	unset($_SESSION["isadmin"]);
	echo "1";
	
}

if($classpost=="tosearch"){
	$ser = $quesy -> ToSearch($classvideo,$userid);
	echo $ser;
}

if($classpost == "getlist"){
	
	echo $quesy -> GetVideoList();
	
}

if($classpost=="addlove"){
	
	echo $quesy -> AddLove($id,$userid);
	
}

if($classpost=="dellove"){
	
	echo $quesy -> DELLove($id,$userid);
	
}

if($classpost=="login"){
	
	echo $quesy -> Login($userName,$pwds);
	
}

if($classpost =="iwatch"){
	
	echo $quesy -> IWatch($id);
	
}



?>